home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Languguage OS 2
/
Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO
/
language
/
embedded
/
develop
/
libsrc11.arc
/
MODL.S
< prev
next >
Wrap
Text File
|
1989-04-27
|
1KB
|
58 lines
******************************************************************************
* modl.s 3.1 11/12/84
*
* 68HC11 CROSS C COMPILER RUN-TIME LIBRARY
*
* (c) Copyright 1984, Motorola, Inc.
*
* FUNCTION NAME: .modl
*
* ACTION: Calculate the modulus of two 16-bit signed integers.
*
* REGISTERS AND STACK:
*
* ON ENTRY: X: FP (frame pointer)
* D: Dividend
* Y: Divisor
*
* STACK: Return Address
* SP:
*
* ON EXIT: X: FP
* D: Modulus
*
* STACK: Previous Contents
* SP:
*
******************************************************************************
psct
xdef .modl
.modl:
pshx save FP
psha sign of dividend
tsta is dividend > 0?
bpl mod1 yes
coma no..negate
comb
addd #1
mod1: pshy copy divisor
pulx ..to X
cpx #0 is divisior > 0?
bpl mod2 yes
xgdx no..negate
coma
comb
xgdx
inx
mod2: idiv do division D/X
tsx use X to access sign byte
tst 0,%x is sign positive?
bpl mod3 yes
coma no..negate
comb
addd #1
mod3: ins discard sign byte
pulx restore FP
rts return
end